#include <interfacelib/Window/MessageBox.h>

using namespace interfacelib::Window;
MessageBox::MessageBox() 
{
	ZeroMemory( m_button, sizeof( m_button ) );
	m_selectIndex = -1;
}

MessageBox::~MessageBox()
{
}

bool MessageBox::addButton( DWORD x, DWORD y, const char *imageName , BYTE index )
{
	if ( m_button[ index ] )
	{
		remove( m_button[ index ] );
	}
	{
		m_button[ index ] = new interfacelib::Window::Button;
			
		m_button[ index ]->create( imageName, x, y );

		add( m_button[ index ] );
	}
	return ( true );
}

void MessageBox::buttonNotify( interfacelib::Window::Window *window )
{
	for ( BYTE i = 0 ; i < MESSAGEBOX_BUTTON_COUNT; i++ )
	{
		if ( window == m_button[ i ] )
		{
			m_selectIndex = i;
			CLOSE_MODAL_DIALOG( NULL, this );
			return;
		}
	}
	
}

void MessageBox::setTextPos( DWORD x, DWORD y , DWORD width, DWORD heigth )
{
	if ( m_textView )
	{
		remove( m_textView );
	}
	{
		m_textView = new interfacelib::Window::EditBox;
		m_textView->create( NULL, x, y );
		m_textView->setWindowPos( x, y, width, heigth );

		m_textView->setMultiLine( true );
		m_textView->setReadOnly( true );

		m_textView->setFormat( DT_CENTER );

		add( m_textView );
		
	}
}

void MessageBox::addText( const char *string )
{
	m_textView->setString( string );
}
